package com.example.demo.control;

import com.alibaba.fastjson.JSON;
import com.example.demo.pojo.Worktype;
import com.example.demo.service.WorkTypeService;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@ResponseBody
@Controller
public class WorkTypeControl {
    @Resource
    WorkTypeService workTypeService;
    @PostMapping("/c/WorkTypeControl/show")
    public String WorkTypeControl(String thispage){
       PageInfo<Worktype> worktypePageInfo= workTypeService.worktypeinfo(Integer.parseInt(thispage),5,"","");
        return JSON.toJSONString(worktypePageInfo);
    }

    @PostMapping("/c/WorkTypeControl/update")
    public String updateWorkTypeControl(String name,String seq){
         String message=workTypeService.updatework(name,seq);
        return message;
    }

    @PostMapping("/c/WorkTypeControl/insert")
    public String insertWorkTypeControl(String name){
        String message=workTypeService.workinsert(name);
        return message;
    }

    @PostMapping("/c/WorkTypeControl/delete")
    public String deleteWorkTypeControl(String seq){
        String message =workTypeService.workdelete(seq);
        return message;
    }
}
